<?php
namespace app\controller;


use app\extensions\api\BigQuery;
use app\extensions\lib\Output;
use support\Request;

class Statistics
{
    public function getFireBaseMessaging(Request $request){

        $package_id = $request->input('package_id');
        $request_id = $request->input('request_id');
        $message_id = $request->input('message_id');
        $page = $request->input('page',1);
        $limit = $request->input('limit',1000);
        $event = $request->input('event','MESSAGE_ACCEPTED');
        $where = [
            'event' => $event,
        ];
        if($request_id){
            $where['analytics_label'] = $request_id;
        }
        if($message_id){
            $where['message_id'] = !is_array($message_id) ? explode(',',$message_id) : $message_id;
        }
        $query = ['total'];
        $is_list = $request->input('is_list',0);
        $is_list && $query[] = 'list';
        $data = BigQuery::getFireBaseMessaging($package_id,$where,$query,$page,$limit);
        return Output::success($data);

    }

}